﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BKH.BLL
{
    class NguoiNhaBUO:IBUO<tbl_ThanNhan>
    {
        HospitalDBDataContext context = new HospitalDBDataContext();
        public bool Insert(tbl_ThanNhan obj)
        {
            try
            {
                context.tbl_ThanNhans.InsertOnSubmit(obj);
                context.SubmitChanges();
                return true;
            }
            catch (Exception)
            {

                return false;
            }
        }

        public bool Delete(int id)
        {
            throw new NotImplementedException();
        }

        public bool Delete(tbl_ThanNhan obj)
        {
            throw new NotImplementedException();
        }

        public List<tbl_ThanNhan> GetAll()
        {
            throw new NotImplementedException();
        }

        public tbl_ThanNhan GetSingle(int id)
        {
            return context.tbl_ThanNhans.Where(n => n.BenhNhanID == id).ToList<tbl_ThanNhan>().FirstOrDefault();
        }

        public bool Update(int id, tbl_ThanNhan obj)
        {
            try
            {
                tbl_ThanNhan ngNha = context.tbl_ThanNhans.Where(n => n.BenhNhanID == id).ToList<tbl_ThanNhan>().FirstOrDefault();
                ngNha = obj;
                context.SubmitChanges();
                return true;
            }
            catch (Exception)
            {

                return false;
            }
        }
    }
}
